home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <strings.h>
- #include <ctype.h>
- #include "missing.h"
- #include "bed.h"
-
- /* $Id: config.c,v 1.2 1993/08/15 20:45:35 vincent Exp $ */
- /* $Log: config.c,v $
- * Revision 1.2 1993/08/15 20:45:35 vincent
- * fix nombre d'area (pb fgets)
- * */
-
- char *skip_blanks(char *string)
- {
- while (*string && isspace(*string)) ++string;
- return string;
- }
-
- char *skip_to_blank(char *string)
- {
- while (*string && !isspace(*string)) ++string;
- return string;
- }
-
- int readconfig(void)
- {
- FILE *conf;
- char temp[100], *p, *q;
-
- /* read tb.cfg */
- sprintf (temp, "%s/tb.cfg", getenv("MAILER"));
- conf=fopen(temp, "r");
- if (conf==NULL)
- return FALSE;
- ourzone=0;
- while (!feof(conf)) {
- fgets (temp, 100, conf);
- if (temp[strlen(temp)-1]=='\n')
- temp[strlen(temp)-1]=0;
- if ((!strnicmp("address", temp, 7)) && (ourzone==0)) {
- /* parse only the first address line */
- p=skip_blanks(temp+7);
- ourpoint=0;
- sscanf (p, "%d:%d/%d.%d", &ourzone, &ournet, &ournode, &ourpoint);
- }
- if (!strnicmp("sysop", temp, 5)) {
- p=skip_blanks(temp+5);
- q=skip_to_blank(p);
- if (!q)
- *q='\0';
- strcpy (sysop, p);
- }
- if (!strnicmp("netmail", temp, 7)) {
- p=skip_blanks(temp+7);
- q=skip_to_blank(p);
- if (!q)
- *q='\0';
- strcpy (areas[0].area_file, p);
- strcpy (areas[0].area_name, "FidoNetmail");
- areas[0].lastread=areas[0].flags=0;
- }
- }
- fclose (conf);
- return TRUE;
- }
-
- int readareas(void)
- {
- FILE *conf;
- char temp[100], *p, *q;
- int i;
-
- num_areas=1;
- /* read areas.bbs */
- sprintf (temp, "%s/areas.bbs", getenv("MAILER"));
- conf=fopen(temp, "r");
- if (conf==NULL)
- return FALSE;
- fgets (temp, 100, conf); /* origin */
- while (!feof(conf)) {
- if (fgets (temp, 100, conf)==NULL) break;
- if ((temp[0]==';') || (temp[0]=='-') || (temp[0]=='\n'))
- temp[0]='\0';
- if (temp[0]!='\0') {
- p=skip_to_blank(temp);
- *p='\0';
- if ((!stricmp("passthru", temp)) || (!stricmp("mail", temp)))
- break;
- strcpy (areas[num_areas].area_file, temp);
- p=skip_blanks(p+1);
- q=skip_to_blank(p);
- if (q)
- *q=0;
- strcpy (areas[num_areas].area_name, p);
- areas[num_areas].flags=0;
- areas[num_areas].lastread=0;
- num_areas++;
- }
- }
- fclose (conf);
-
- /* read led.new */
- sprintf (temp, "%s/led.new", getenv("MAILER"));
- conf=fopen(temp, "r");
- if (conf==NULL)
- return TRUE;
- while (!feof(conf)) {
- fgets (temp, 80, conf);
- p=skip_to_blank(temp);
- *p=0;
- p=skip_blanks(p+1);
- for (i=0; i<num_areas; i++)
- if (!strcmp(temp, areas[i].area_name)) {
- areas[i].lastread=atoi(p);
- areas[i].flags=atoi(skip_blanks(skip_to_blank(p)));
- }
- }
-
- fclose (conf);
- return TRUE;
- }
-